<form id="formEdit">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">操作</h4>
            </div>
            <div class="modal-body">
            	<!-- 以下为要修改的的内容 -->
				<input type="hidden" name="id" data-th-value="${model.id}">
                <div class="form-group">
                	<label for="txt_testId">考试名称</label>
                    <select id="txt_testId" name="testId" class="form-control">
                    	<option data-th-each="test:${tests}" data-th-value="${test.id}" data-th-text="${test.name}" data-th-selected="${model.test!=null&&test.id==model.test.id}"></option>
                    </select>
                </div>
                <div class="form-group">
                	<label for="txt_studentId">学生</label>
                    <select id="txt_studentId" name="studentId" class="form-control">
                    	<option data-th-each="student:${students}" data-th-value="${student.id}" data-th-text="${student.name}" data-th-selected="${model.student!=null&&student.id==model.student.id}"></option>
                    </select>
                </div>
                <div class="form-group">
                	<label for="txt_userName">登录名</label>
                    <input type="text" name="userName" data-th-value="${model.userName}" class="form-control" id="txt_userName" placeholder="用户名">
                </div>
                <div class="form-group">
                	<label for="txt_pwd">密码</label>
                    <input type="text" name="pwd" data-th-value="${model.pwd}" class="form-control" id="txt_pwd" placeholder="密码">
                </div>
                <div class="form-group">
                	<label for="txt_projectUrl">项目地址</label>
                    <input type="text" name="projectUrl" data-th-value="${model.projectUrl}" class="form-control" id="txt_projectUrl" placeholder="项目地址">
                </div>
                <div class="form-group">
                	<label for="txt_sourceUrl">源码地址</label>
                    <input type="text" name="sourceUrl" data-th-value="${model.sourceUrl}" class="form-control" id="txt_sourceUrl" placeholder="项目地址">
                </div>
                <div class="form-group" sec:authorize="hasRole('ROLE_ADMIN')">
                	<label for="txt_isShow">主页展示</label>
                    <select name="isShow" class="form-control">
                    	<option style="display: none;" value="">请选择</option>
                    	<option value="true" data-th-selected="${model.isShow!=null&&model.isShow}">是</option>
                    	<option value="false" data-th-selected="${model.isShow==null||!model.isShow}">否</option>
                    </select>
                </div>
                
				
                <!-- 以上为要修改的内容 -->
            </div>
            <div class="modal-footer">
                <button type="submit" class="btn btn-primary"><span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span>保存</button>
                <button type="button" class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span>关闭</button>
            </div>
        </div>
    </div>
</form>
<script type="text/javascript" th:inline="javascript">
    $(function () {
 		var options= {
			message: '验证不通过',
			feedbackIcons: {
              valid: 'glyphicon glyphicon-ok',
              invalid: 'glyphicon glyphicon-remove',
              validating: 'glyphicon glyphicon-refresh'
          	},
          	fields:  {
				name: {
					validators: {
						notEmpty: {
							message: '考试不能为空'
						}
					}
				},
				testDate: {
					validators: {
						notEmpty: {
							message: '考试时间不能为空'
						},
						date:{
							format : 'YYYY-MM-DD',
							message:'请输入有效的日期格式:yyyy-MM-dd'
						}
					}
				},
				xq: {
					validators: {
						notEmpty: {
							message: '生日不能为空'
						}
					}
				}
        	}
		};
        $('#formEdit').bootstrapValidator(options).on('success.form.bv', function(e) {
        	e.preventDefault();							   	//很重要没有它则会提交默认表单，不会做下面的ajax表单提交
            var fd = new FormData($("#formEdit")[0]);
            $.ajax({  
              url: "save",  
              type: "POST",  
              data: fd,  
              processData: false,  // 不处理数据  
              contentType: false,   // 不设置内容类型
              success:function(data){
            	  if(!data.success){
            		  bootbox.alert(data.msg);
            	  }
            	  $('#myModal').modal("hide");
              }
            });  
        });

    });
</script>